﻿using System;

namespace Chip8.Core.Processor.Operations
{
	internal class AND : Operation
	{
		public AND(int targetRegisterIndex, int sourceRegisterIndex)
		{
			SourceRegisterIndex = sourceRegisterIndex;
			TargetRegisterIndex = targetRegisterIndex;
		}

		public int SourceRegisterIndex { get; set; }

		public int TargetRegisterIndex { get; set; }

		public override void Execute(ICPU cpu)
		{
			var result = cpu.V[TargetRegisterIndex] & cpu.V[SourceRegisterIndex];
			cpu.V[TargetRegisterIndex] = (byte)result;
		}
	}
}